﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }



        protected void Button1_Click(object sender, EventArgs e)
        {

            if (FileUpload1.HasFile)
            {
                string fileExt =System.IO.Path.GetExtension(FileUpload1.FileName);

                string distination = @"C:\Documents and Settings\khedidja.aoukli\Mes documents\Browser-08-2011\Browser-28-04\Browser\Browser\Dico\";

                if (fileExt == ".xml")
                {
                    try
                    {
                        FileUpload1.SaveAs(distination+FileUpload1.FileName);

                        Label1.Text = "File name: " +
                            FileUpload1.PostedFile.FileName + "<br>" +
                            FileUpload1.PostedFile.ContentLength + " kb<br>" +
                            "Content type: " +
                            FileUpload1.PostedFile.ContentType
                            + "Location where saved: " +
                             distination + "\\" +
                             System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName) + ""; 

                    }
                    catch (Exception ex)
                    {
                        Label1.Text = "ERROR: " + ex.Message.ToString();
                    }
                }
                else
                {
                    Label1.Text = "Only .xml files allowed!";
                }
            }
            else
            {
                Label1.Text = "You have not specified a file.";
            }
        }
       
    }
}